package com.example.redis.controller;

import com.example.redis.bean.User;
import com.example.redis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Copyright(C), 2020-2021, AmbroseCdMeng
 * FileName:    RedisController
 * Author:      AmbroseCdMeng
 * Date:        2021/2/27 9:29
 * Description: 增、删、改、查 API 测试
 * History:
 * <author>     <time>      <version>       <desc>
 * 作者姓名     修改时间        版本号           描述
 */
@RestController
@RequestMapping("/user")
public class RedisController {
    @Autowired
    UserService userService;

    @RequestMapping("/{id}")
    public User ForTest(@PathVariable String id){
        return userService.selectUser(id);
    }

    @RequestMapping("/update/")
    public String update(User user){
        userService.updateById(user);
        return "update success";
    }

    @RequestMapping("/delete/{id}")
    public String delete(@PathVariable String id){
        userService.deleteById(id);
        return "delete success";
    }
}
